package com.cmhi.softmbh.activity;

import android.app.Activity;
import android.app.DevInfoManager;
import android.os.Bundle;
import android.view.WindowManager;
import android.widget.TextView;

import com.chinamobile.SWDevInfoManager;
import com.cmhi.softmbh.R;
import com.softmbh.kellyplatform.util.AppUtils;

public class HiddenActivity extends Activity {

    SWDevInfoManager devInfoManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //禁止系统息屏，在 setContentView(R.activity_install.activity_main); 前调用
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        setContentView(R.layout.activity_hidden);
        try {
            devInfoManager = SWDevInfoManager.getInstance(this);
            getZwData(R.id.hdcrurl, DevInfoManager.HDCRURL);
            getZwData(R.id.epg_address, DevInfoManager.EPG_ADDRESS);
            getZwData(R.id.cdn_address, DevInfoManager.CDN_ADDRESS);
            getZwData(R.id.backup_cdn_address, DevInfoManager.CDN_ADDRESS_BACK);
            getZwData(R.id.tv_id, DevInfoManager.TV_ID);
            getZwData(R.id.cdn_type, DevInfoManager.CDN_TYPE);
            getZwData(R.id.platform_url_zte, DevInfoManager.PLAT_URL_ZTE);
            getZwData(R.id.platform_url_backup_zte, DevInfoManager.PLAT_URL_ZTE_BACK);
            getZwData(R.id.cdn_dispatch_url, DevInfoManager.CDN_DISPATCH_URL);
            getZwData(R.id.cdn_dispatch_url_backup, DevInfoManager.CDN_DISPATCH_URL_BACK);
            getZwData(R.id.launcher, DevInfoManager.LAUNCHER);
            getZwData(R.id.ott_terminal_type, DevInfoManager.OTT_TERMINAL_TYPE);
            getZwData(R.id.active_user_type, DevInfoManager.ACTIVE_USER_TYPE);
        } catch (Exception e) {
            AppUtils.debugLog("error : " + e);
            e.printStackTrace();
        }
    }

    //读取卓望数据
    private void getZwData(int id, String key) {
        try {
            devInfoManager.getValue(key, value -> {
                AppUtils.debugLog(key + " : " + value);
                ((TextView) findViewById(id)).setText(value);
            });
        } catch (Exception e) {
            AppUtils.debugLog("error : " + e);
            e.printStackTrace();
        }
    }
}
